package com.itcat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcat.mysql.pojo.CmsPrefrenceAreaProductRelation;
import com.itcat.mysql.pojo.PmsProductAttributeValue;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 小心触碰的电脑
* @description 针对表【pms_product_attribute_value(存储产品参数信息的表)】的数据库操作Mapper
* @createDate 2022-04-03 16:17:40
* @Entity com.itcat.mysql.pojo.PmsProductAttributeValue
*/
@Mapper
public interface PmsProductAttributeValueMapper extends BaseMapper<PmsProductAttributeValue> {


    @Insert({"<script> " +
            "insert into pms_product_attribute_value  ( product_id, product_attribute_id, value)values" +
            " <foreach collection='list' item='item' index='index' separator=',' > " +
            "( #{item.productId}, #{item.productAttributeId}, #{item.value})" +
            "</foreach>" +
            "</script>"})
    int batchInsert(@Param("list") List<PmsProductAttributeValue> list);

    @Update({"<script> " +
            "<foreach collection='list' item='item' index='index' separator=';'> " +
            "UPDATE pms_product_attribute_value " +
            "SET product_id = #{item.productId}, product_attribute_id= #{item.productAttributeId}, value= #{item.value} " +
            "WHERE id = #{item.id} </foreach> </script>"})
    int batchUpdate(@Param("list") List<PmsProductAttributeValue> list);
}
